package com.eps.entity;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Arturo
 */
@Entity
@Table(name = "Departamento")
@NamedQueries({
    @NamedQuery(name = "Departamento.findAll", query = "SELECT d FROM Departamento d"),
    @NamedQuery(name = "Departamento.findByCoddepto", query = "SELECT d FROM Departamento d WHERE d.coddepto = :coddepto"),
    @NamedQuery(name = "Departamento.findByNomDepartamento", query = "SELECT d FROM Departamento d WHERE d.nomDepartamento = :nomDepartamento")})
public class Departamento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Cod_depto")
    private String coddepto;
    @Basic(optional = false)
    @Column(name = "nom_departamento")
    private String nomDepartamento;
    @JoinColumn(name = "Cod_pais", referencedColumnName = "Cod_pais")
    @ManyToOne(optional = false)
    private Pais codpais;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "coddepto")
    private List<Provincia> provinciaList;

    public Departamento() {
    }

    public Departamento(String coddepto) {
        this.coddepto = coddepto;
    }

    public Departamento(String coddepto, String nomDepartamento) {
        this.coddepto = coddepto;
        this.nomDepartamento = nomDepartamento;
    }

    public String getCoddepto() {
        return coddepto;
    }

    public void setCoddepto(String coddepto) {
        this.coddepto = coddepto;
    }

    public String getNomDepartamento() {
        return nomDepartamento;
    }

    public void setNomDepartamento(String nomDepartamento) {
        this.nomDepartamento = nomDepartamento;
    }

    public Pais getCodpais() {
        return codpais;
    }

    public void setCodpais(Pais codpais) {
        this.codpais = codpais;
    }

    public List<Provincia> getProvinciaList() {
        return provinciaList;
    }

    public void setProvinciaList(List<Provincia> provinciaList) {
        this.provinciaList = provinciaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (coddepto != null ? coddepto.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {

        if (!(object instanceof Departamento)) {
            return false;
        }
        Departamento other = (Departamento) object;
        if ((this.coddepto == null && other.coddepto != null) || (this.coddepto != null && !this.coddepto.equals(other.coddepto))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "suministros.ejb30.entity.Departamento[coddepto=" + coddepto + "]";
    }

}
